package com.example.myapplication.TiKuAdapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.myapplication.TiKuBean.TiKuBean;
import com.example.myapplication.R;
import com.example.myapplication.WuChangFuBenActivity.WuChangFuBen;

import java.util.ArrayList;
import java.util.List;

public class TiKuAdapter extends BaseAdapter{
    List<TiKuBean>list=new ArrayList<>();
    Activity activity;
    Context context;

    public TiKuAdapter(List<TiKuBean> list, Activity activity,Context context) {
        this.list = list;
        this.activity = activity;
        this.context=context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view= LayoutInflater.from(activity).inflate(R.layout.tiku_mokuai,null);
        TextView biaoti=view.findViewById(R.id.TiKu_biaoti);
        TextView text=view.findViewById(R.id.TiKu_text);
        TextView zhuangtai=view.findViewById(R.id.TiKu_zhuangtai);
        biaoti.setText(list.get(i).getBiaoti());
        text.setText(list.get(i).getText());
        zhuangtai.setText(list.get(i).getZhuangtai());

        biaoti.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(context,WuChangFuBen.class);
                Bundle bundle=new Bundle();
                bundle.putString("biaoti",list.get(i).getBiaoti());
                intent.putExtras(bundle);
                context.startActivity(intent);
            }
        });
        text.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(context,WuChangFuBen.class);
                Bundle bundle=new Bundle();
                bundle.putString("biaoti",list.get(i).getBiaoti());
                intent.putExtras(bundle);
                context.startActivity(intent);
            }
        });
        zhuangtai.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(context,WuChangFuBen.class);
                Bundle bundle=new Bundle();
                bundle.putString("biaoti",list.get(i).getBiaoti());
                bundle.putString("zhuangtai",list.get(i).getZhuangtai());
                intent.putExtras(bundle);
                context.startActivity(intent);
            }
        });
        return view;
    }

}
